from typing import *


class Solution:
    def getSubarrayBeauty(self, nums: List[int], k: int, x: int) -> List[int]:
        h = [0] * 101
        ans = []
        for i, v in enumerate(nums):
            h[v+50] += 1
            if i >= k:
                h[nums[i - k] + 50] -= 1
            cnt, j = 0, -1
            while cnt < x and j < 100:
                j += 1
                if h[j] != 0:
                    cnt += h[j]
            if i >= k - 1:
                if j < 50:
                    ans.append(j-50)
                else:
                    ans.append(0)
        return ans


s = Solution()
# print(s.getSubarrayBeauty(nums=[1, -1, -3, -2, 3], k=3, x=2))
# print(s.getSubarrayBeauty(nums=[-46, -34, -46], k=3, x=3))
print(s.getSubarrayBeauty(nums=[-21, -24, 50], k=2, x=2))

2
2
